package br.com.massai.model.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "URL")
public class Url extends GenericEntity {

	private static final long serialVersionUID = 287103163065667682L;

	@Id
	@SequenceGenerator(name = "seqUrl", sequenceName = "seq_url", allocationSize = 1)
	@GeneratedValue(generator = "seqUrl", strategy = GenerationType.SEQUENCE)
	private Long id;

	@Column(name = "URL", nullable = false, unique = true, columnDefinition = "TEXT")
	private String url;
	
	@ManyToOne(optional = false)
	@JoinColumn(name = "FUNCTION_ID" , referencedColumnName = "ID")
	private Function function;
	
	@Override
	public boolean equals(Object obj) {
		if(obj == null) return false;
		if(obj instanceof Url)
			if(((Url)obj).getId().equals(this.getId())) return true;
		return false;
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Function getFunction() {
		return function;
	}

	public void setFunction(Function function) {
		this.function = function;
	}
}